/**
 * 数字转成汉字
 * @params number === 要转换的数字
 * @return 汉字
 * */
const toChinesNumber=(number)=> {
    let changeNumber = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
    let unit = ['', '十', '百', '千', '万']
    number = parseInt(number)
    let getWan = (temp) => {
        let strArr = temp.toString().split('').reverse()
        let newNumber = ''
        let newArr = []
        strArr.forEach((item, index) => {
            newArr.unshift(item === '0' ? changeNumber[item] : changeNumber[item] + unit[index])
        })
        let numberArr = []
        newArr.forEach((m, n) => {
            if (m !== '零') numberArr.push(n)
        })
        if (newArr.length > 1) {
            newArr.forEach((m, n) => {
                if (newArr[newArr.length - 1] === '零') {
                    if (n <= numberArr[numberArr.length - 1]) {
                        newNumber += m
                    }
                } else {
                    newNumber += m
                }
            })
        } else {
            newNumber = newArr[0]
        }

        return newNumber
    }
    let overWan = Math.floor(number / 10000)
    let noWan = number % 10000
    if (noWan.toString().length < 4) {
        noWan = '0' + noWan
    }
    return overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(number)
}
export {
    toChinesNumber
}